<?php require_once('./header.php');
function rep($type) {
    $replace = array(
        '{{foreach:news}}'=>'{{foreach:comic_news:reverse}}',
        '{{endeach:news}}'=>'{{endeach:comic_news}}',
        '{{foreach:main}}'=>'{{foreach:'.$type.'}}',
        '{{endeach:main}}'=>'{{endeach:'.$type.'}}',
        '{{endeach}}'=>'{{endeach:'.$type.'}}',
        '{!eval {{bool_comic_title}}?{{!ev_comic_title}}:!:Untitled Comic!}'=>'{{if:comic_title}}{{comic_title}}{{else}}Untitled Comic{{endif}}',
        '<p>{{comic_blurb}}</p>'=>'{{comic_blurb:rich}}',
        '{{comic_blurb}}'=>'{{comic_blurb:rich}}',
        '<p>{{news_post}}</p>'=>'{{news_post:rich}}',
        '{{news_post}}'=>'{{news_post:rich}}',
        '{{import:dropdownform|{{comic_id}}}}'=>'{{plugin:dropdownform}}',
        '{{import:navbar|{{comic_id}}}}'=>'<div class="navbar">
        {{if:prev_comic}}
            <a href="http:///?id={{first_comic_id}}" title="{{first_comic_title}}">First</a>
            | <a href="http:///?id={{prev_comic_id}}" title="{{prev_comic_title}}">Prev</a>
        {{else}}
            First | Prev
        {{endif}}
        |
        {{if:next_comic}}
            <a href="http:///?id={{next_comic_id}}" title="{{next_comic_title}}">Next</a>
            | <a href="http:///?id={{last_comic_id}}" title="{{last_comic_title}}">Last</a>
        {{else}}
            Next | Last
        {{endif}}
    </div>',
        '_username'=>'_author_name',
    );
    return $replace;
}
function templatefile($t,$type=false) {
    $content = file('./storage/templates/'.$t.'.tpl');
    if ($type) {
        array_pop($content);
        array_shift($content);
    }
    return htmlspecialchars(strtr(implode($content),rep($type)));
}
?>
        <h1>Tweak that template</h1>
        <p>Changed your mind about this? At this point you can still <a href="step2.php">go back</a>, download your current template and use the new default.</p>
        <p>We suggest you stay on this page for as little time as possible. Just alter what you're told to alter and do the fine tweaking later. It's much more plesent, and safer, to edit your templates in the ComicCMS admin panel than here.</p>
        <strong>The http:/// displayed throughout this page is a shortcut to your base URL and is correct to have in your templates</strong>
        
        <form action="mtemplate2.php" method="post">
            <h2>Header</h2>
            <p>Your header template is shown below, we need to tweak it a bit.</p>
            <p>You need to get rid of the link to the current RSS feed (the &lt;link rel="alternate"... tag), and the &lt;meta name="generator" tag, then you need to put in it's place the following:</p>
            <pre>  &lt;meta name="generator" content="ComicCMS" /&gt;
  &lt;link rel="alternate" type="application/rss+xml" title="Comic RSS" href="http:///inc/feed.php" /&gt;
  &lt;link rel="stylesheet" href="http:///inc/css.php" type="text/css" /&gt;</pre>
            <h3>Header Template</h3>
            <textarea name="header"><?php echo templatefile('header'); ?></textarea>
            
            
            <h2>CSS</h2>
            <p>ComicCMS now supports external CSS files. This makes your header smaller and lowers the bandwidth of your site. Cool!</p>
            <p>From your header template (above) you need to cut out the CSS from within the &lt;style&gt; tags <strong>But not the style tags themselves!</strong> and copy them into the box below, then delete the style tags from your header template.</p>
            <p>So below is just the CSS rules without any HTML tags, and in your header should be very little :)</p>
            <h3>CSS Template</h3>
            <textarea name="css"></textarea>
            
            
            <h2>Footer</h2>
            <p>We've taken the {{timestamp}} variable out of ComicCMS for this version, so you'll want to take that out of your template. You can, however, use "{{magic_executetime}} seconds" if you want to brag at how fast ComicCMS loads your page!</p>
            <p>You may also want to put a link to your admin panel in there so you don't forget, e.g. &lt;a href="http:///admin/"&gt;Admin&lt;/a&gt;. Suggestion:</p>
            <pre>&lt;p style="font-size:10px; text-align:center; clear:both;"&gt;-
&lt;a href="http:///admin/" style="text-decoration:underline; color:inherit;"&gt;Admin&lt;/a&gt; -&lt;br /&gt;
Generated by &lt;a href="http://comiccms.com/" target="_blank" style="text-decoration:underline; color:inherit;"&gt;
ComicCMS&lt;/a&gt;&lt;br /&gt;{{magic_executetime}} seconds&lt;/p&gt;</pre>
            <h3>Footer Template</h3>
            <textarea name="footer"><?php echo templatefile('footer'); ?></textarea>
            
            
            
            <h1>OK, that's the global bits done</h1>
            <p>Time for a breather. You've now converted the global bits of your site and now we're moving on to individual pages. It's not too hard but let me just clue you in on something first.</p>
            <p>Variable operators can be used in ComicCMS variables (you know, {{these_kind}} of things) to transform how it is displayed. For example, you could have: {{comic_month}}, {{comic_month:pad}}, {{comic_month:name}} or {{comic_month:shortname}}. Which would show: 4, 04, April or Apr </p>
            <p>Full details of this are in the ComicCMS user manual. This is just so you know what is going on here.</p>
            
            
            <h2>Comics</h2>
            <p>We've automatically changed your templates here to get you started, there's just a few more bits you may want to add in yourself.</p>
            <p>We now have the variable {{comic_tagline}}, and suggest you put that as the title attribute of your comic image tag. ( title="{{comic_tagline}}" somewhere in the &lt;img tag)</p>
            <p>News posts can now be formatted with BBCode and this has been added to your template ({{news_post:rich}}), if you are desperate to keep HTML formatting on your news posts (not the safest option!) then you can change it to {{news_post:full}}.</p>
            <p>The {{import:navbar}} plugin no longer exists, and has been replaced by a chunk of if statements. This has been automatically changed for you but means you'll have lost any changes you made to the navbar plugin.</p>
            <h3>Main Page Template</h3>
            <textarea name="main"><?php echo templatefile('index','comic'); ?></textarea>
            
            <h3>Individual Comic Pages Template</h3>
            <textarea name="comic"><?php echo templatefile('comic','comic'); ?></textarea>
            
            
            
            <h2>News</h2>
            <p>Same goes here, we've changed some bits already, news posts are now formatted with BBCode and you can change it to {{news_post:full}} if you must.</p>
            <h3>Each News Post Template</h3>
            <textarea name="post"><?php echo templatefile('newspage','news'); ?></textarea>
            <p>We won't bother editing the archive pages, and any custom pages you may have added will be converted over automatically so this is all done.</p>
            
            <input type="submit" name="mtemplate" value="Save Template" />
        </form>
        
    </div>
</body>
</html>